from waitress import serve
import os

from wsgi import application

from whitenoise import WhiteNoise

application = WhiteNoise(application, )

current_dir = os.path.dirname(__file__)
root_path = os.path.dirname( os.path.dirname(__file__) )

application.add_files(root=os.path.join(root_path,'media'), prefix='media')
application.add_files(root=os.path.join( current_dir,'static'), prefix='static')


def start():
    print('开始')
    serve(application, port='8077')
    print('退出')
    
if __name__ == '__main__':
    #import webview
    #thread = threading.Thread(target=start)
    #thread .start()
    serve(application, port='8077')
    #webview.create_window('Hello world', 'http://localhost:8077')
    #webview.start()  
    #os.kill(os.getpid(), signal.SIGINT)
    #glob['serve'].shutdown()